package com.service;

import java.sql.SQLException;
import java.util.List;

import com.dao.impl.UserDaoImpl;
import com.po.User;
import com.vo.PageBean;

public class UserService {

	public UserService() {
	}
	
	public PageBean<User> showAllUserByPage(int currPage, int pageSize) throws SQLException {
		//查询当前页数据 limit (当前页-1)*每页显示条数,每页显示条数;
		UserDaoImpl udi = new UserDaoImpl();
		List<User> list=udi.findAllByPage(currPage,pageSize);
		
		//查询总条数
		int totalCount=udi.getCount();
		
		return new PageBean<User>(list, currPage, pageSize, totalCount);
	}
	public PageBean<User> showUserByPageAndCondition(String name, String kw, int currPage, int pageSize) throws SQLException {
		//查询当前页数据 limit (当前页-1)*每页显示条数,每页显示条数;
		UserDaoImpl udi = new UserDaoImpl();
		List<User> list=udi.findByCondition(name, kw, currPage, pageSize);	
		//查询总条数
		int totalCount = udi.getCountByCondition(name, kw);
		return new PageBean<User>(list, currPage, pageSize, totalCount);
	}
	
	public PageBean<User> showUserByPageAndConditionAndLike(String name, String kw, int currPage, int pageSize) throws SQLException {
		//查询当前页数据 limit (当前页-1)*每页显示条数,每页显示条数;
		UserDaoImpl udi = new UserDaoImpl();
		List<User> list=udi.findByConditionAndLike(name, kw, currPage, pageSize);	
		//查询总条数
		int totalCount = udi.getCountByConditionAndLike(name, kw);
		return new PageBean<User>(list, currPage, pageSize, totalCount);
	}
}
